<template tag="以下文档内容为hycli自动生成">
  <div style="height: 100%">
    <div style="margin:0.8rem;"><h5 style="display:inline">文档</h5><span style="margin-left: 0.5rem; color:#999"> 设计文档、开发文档等管理</span>
        <ddmenu :menuList="lob_idList" @valueChanged="onlob_idChange" v-model="form_aaaem.lob_id" menuType="my_business_line" ></ddmenu>
    </div>
    <hr style="margin-top:0;color:#999"/>
<div class="query">
    
    <div class="tabs">
        <el-tabs v-model="form_aaaem.archive_status"  @tab-change="onQuery">
            <el-tab-pane v-for="item in archive_statusTabList" :name="item.value" :key="item.value" :label="item.name" 
             ></el-tab-pane>
          </el-tabs>
    </div>
    <el-form :model="form_aaaem" inline >
        <!-- 日期控件个数： 1 -->
        <el-form-item>
            <!--多日期范围控件 -->
            <el-select v-model="form_aaaem.single_date_range_name" filterable placeholder="日期类型" style="width:120px;" class="prepend">
                <el-option
                v-for="item in multiQueryDateRange"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
        </el-select>
            <el-date-picker :shortcuts="shortcuts" style="width: 200px" v-model="form_aaaem.single_date_range_value" type="daterange" start-placeholder="开始日期"
                end-placeholder="结束日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
        </el-form-item>
        <!--研发计划 下拉控件 -->
        <el-form-item>
            <el-select  v-model="form_aaaem.plan_id" style="width: 100px" filterable clearable placeholder="研发计划">
                <el-option v-for="item in plan_idList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!-- 控件个数：[{"index":107,"raw":"doc_name","name":"doc_name","cname":"DocName","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["bq","l","c","u","le","q","v","DN","#like"],"desc":{"raw":"名称","name":"名称"}}] -->
         <el-form-item>
            <el-input clearable style="width: 180px" v-model="form_aaaem.single_text_value" maxlength="32"
                placeholder="关键字" >
                <template #prepend>
                    <el-select v-model="form_aaaem.single_text_name" placeholder="查询类型" style="width:84px;">
                        <el-option
                        v-for="item in multiQueryText"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                      </el-select>
                  </template>
            </el-input>
        </el-form-item>

        <span class="ddl">
        </span>
        <el-form-item>
            <el-space wrap>
                <el-button type="primary" icon="Search" @click="onQuery(true)">查询</el-button>
                <el-button :type="$js.page.tagColor(0)"  icon="Plus"  @click="show_cmpnt_aaage">添加文档</el-button>
            </el-space>
        </el-form-item>
        

        <!-- xtabs -->
        
        <div class="tabs">
            <el-tabs v-model="form_aaaem.doc_type"  @tab-change="onQuery">
                <el-tab-pane name="" label="全部"  ></el-tab-pane>
                <el-tab-pane v-for="item in doc_typeList" :name="item.value" :key="item.value" :label="item.name" 
                 ></el-tab-pane>
              </el-tabs>
        </div>

    </el-form>
</div>
<div>
   <aaage ref="cmpnt_aaage" @onsaved="onQuery"></aaage>
   <aaagd ref="cmpnt_aaagd" @onsaved="onQuery"></aaagd>
   <aaagb ref="cmpnt_aaagb" @onsaved="onQuery"></aaagb>
   <aaagc ref="cmpnt_aaagc" @onsaved="onQuery"></aaagc>
</div>
<div class="list">
    <el-table :data="dataList_aaaem"
    
    v-loading="conf.loading" stripe  style="width: 100%;height:calc(100vh - 160px)"
         empty-text="无数据">le
<el-table-column width="24px" type="expand">
    <template #default="view">
        <el-row :gutter="24">
            <el-col :span="5" class="text-right" style="min-height:26px">编号:</el-col>
            <el-col :span="7" v-text="view.row.le_doc_id" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">任务编号:</el-col>
            <el-col :span="7" v-text="view.row.le_tsk_id" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">名称:</el-col>
            <el-col :span="7" v-text="view.row.le_doc_name" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">类型:</el-col>
            <el-col :span="7" v-text="view.row.doc_type_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">研发计划:</el-col>
            <el-col :span="7" v-text="view.row.plan_id_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">创建时间:</el-col>
            <el-col :span="7" v-text="view.row.le_create_time" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">文档链接:</el-col>
            <el-col :span="7" style="min-height:26px"
            >
                <el-link target="_blank" type="primary" :href="view.row.le_url" v-if="view.row.le_url" :title="view.row.le_url">查看</el-link>
            </el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">说明:</el-col>
            <el-col :span="7" v-html="view.row.le_memo||'-'" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">创建人:</el-col>
            <el-col :span="7" v-text="view.row.creator_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">归档状态:</el-col>
            <el-col :span="7" v-text="view.row.archive_status_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">业务线:</el-col>
            <el-col :span="7" v-text="view.row.lob_id_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">归档时间:</el-col>
            <el-col :span="7" v-text="view.row.le_archive_time" style="min-height:26px" ></el-col>
        </el-row>
    </template>
</el-table-column>
        
        	<!--doc_id text -->
        <el-table-column  v-if="$size.gt('m')"  show-overflow-tooltip    align="center" label="编号" >
            <template #default="scope">
                  <span>{{ scope.row.doc_id||'-' }}</span>
              </template>
        </el-table-column>
        	<!--doc_name text -->
        <el-table-column  show-overflow-tooltip    align="center" label="名称" >
            <template #default="scope">
                  <span>{{ scope.row.doc_name||'-' }}</span>
              </template>
        </el-table-column>
        	<!--doc_type select -->
        <el-table-column  :filters="doc_typeList" :filter-method="$js.page.columnfilter" column-key="doc_type"     prop="doc_type" align="center" label="类型">
            <template #default="scope">
                <span 
                    v-text="scope.row.doc_type_label"></span>
            </template>
        </el-table-column>
        	<!--plan_id select -->
        <el-table-column     prop="plan_id" align="center" label="研发计划">
            <template #default="scope">
                <span 
                    v-text="scope.row.plan_id_label"></span>
            </template>
        </el-table-column>
        	<!--create_time date -->
        <el-table-column  show-overflow-tooltip    align="center" label="创建时间" >
            <template #default="scope">
                  <span>{{ scope.row.create_time||'-' }}</span>
              </template>
        </el-table-column>
        	<!--url link -->
        <el-table-column     align="center" label="文档链接">
            <template #default="scope">
                <el-link target="_blank" type="success" :href="scope.row.url" v-if="scope.row.url" :title="scope.row.url">查看</el-link>
            </template>
        </el-table-column>
        	<!--memo text -->
        <el-table-column  v-if="$size.gt('m')"  show-overflow-tooltip    align="center" label="说明" >
            <template #default="scope">
                  <span>{{ scope.row.memo||'-' }}</span>
              </template>
        </el-table-column>
        	<!--creator select -->
        <el-table-column     prop="creator" align="center" label="创建人">
            <template #default="scope">
                <span 
                    v-text="scope.row.creator_label"></span>
            </template>
        </el-table-column>

<el-table-column fixed="right" align="center" label="操作" width="168">
    <template #default="scope">
        <div class="opts">
            <el-button   type="text" @click="show_cmpnt_aaagd(scope.row)" >详情 </el-button>
            <el-button   type="text" @click="show_cmpnt_aaagb(scope.row)" >编辑 </el-button>
            <el-button   type="text" @click="show_cmpnt_aaagc(scope.row)" >删除 </el-button>
        </div>
    </template>
</el-table-column>
    </el-table>
    <el-pagination :currentPage="form_aaaem.pi" :page-size="form_aaaem.ps"
        style="position: absolute; right: 30px;bottom:6px;" :page-sizes="[10,15,20,30, 50, 100]" :background="false" small
        layout="total,sizes,prev, pager, next, jumper" :total="total_aaaem" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" />
</div>
  </div>
</template>
<script>
// 添加文档
import aaage from "@/views/ws/dev/dev_docs.add"
// 详情
import aaagd from "@/views/ws/dev/dev_docs.view"
// 编辑
import aaagb from "@/views/ws/dev/dev_docs.edit"
// 删除
import aaagc from "@/views/ws/dev/dev_docs.cnfrm"
// 业务线
import ddmenu from "@/views/cmpnts/ddMenu.vue"



export default {
components: {
    aaage,
    aaagd,
    aaagb,
    aaagc,
     ddmenu,
},
data() {
  return {
    shortcuts: this.$js.page.latestDays(),
    cmpnt_funcs:{},
    conf: {
      loading: false,
      progressColor: this.$theia.env.conf.progress || []
    },
    ganttIdx: -1,
        form_aaaem: {
            pi: 1,
            ps: 15,
            disabled:false,
            single_date_range_name:"",
            single_date_range_value:[],
            single_text_name:"",
            single_text_value:"",
            doc_name:"",
            doc_type:"",
            plan_id:"",
            create_time:"",
            archive_status:"",
            lob_id:"",
            },
            doc_typeList:[],
            plan_idList:[],
            creatorList:[],
            archive_statusList:[],
            archive_statusTabList:[],
            lob_idList:[],
            dataList_aaaem:[],
            multiQueryDateRange:[{label:"创建时间",value:"create_time"},],
            multiQueryText:[{label:"名称",value:"doc_name"},],
            total_aaaem:0,
            note_dataList:[],
};
  },
mounted() {
  this.loadEnums_aaaem()
  this.form_aaaem.lob_id = this.$theia.user.get("lob_id")
  this.form_aaaem.single_date_range_name = (this.multiQueryDateRange[0]||{}).value
  this.form_aaaem.single_text_name = (this.multiQueryText[0]||{}).value
  this.cmpnt_funcs["aaage"] = this.show_cmpnt_aaage
  this.cmpnt_funcs["aaagd"] = this.show_cmpnt_aaagd
  this.cmpnt_funcs["aaagb"] = this.show_cmpnt_aaagb
  this.cmpnt_funcs["aaagc"] = this.show_cmpnt_aaagc

  this.form_aaaem = Object.assign(this.form_aaaem,this.$route.params)
  this.queryData_aaaem ()
    },
methods: {
  ganttChange(id) {
      this.ganttIdx = id
    },

queryData_aaaem(mform = {},nform={}){
    //构建查询参数
    let queryForm = Object.assign({},this.form_aaaem)
    queryForm = Object.assign(queryForm,nform||{})
    
    //处理多个日期选择
    queryForm[this.form_aaaem.single_date_range_name] = this.form_aaaem.single_date_range_value
    queryForm[this.form_aaaem.single_text_name] = this.form_aaaem.single_text_value
   
    //处理日期范围选择
      queryForm.start_create_time = null
      queryForm.end_create_time = null
    if(queryForm.create_time && queryForm.create_time.length > 1){
      queryForm.start_create_time = queryForm.create_time[0]
      queryForm.end_create_time = queryForm.create_time[1]
    }

    queryForm[this.form_aaaem.single_date_range_name] = null
    queryForm.single_date_range_value = null
    queryForm.single_date_range_name = null

    queryForm.single_text_value = null
    queryForm.single_text_name = null
 
    //处理关联表dev_docs dev_docs dev_docs
   
    //发送查询请求
    let that = this
    that.conf.loading = true
    //构建统计查询
  //数据查询
  this.$theia.http.get("/ws/dev/docs/query",queryForm).then(res=>{
      if((res.items||[]).length < (queryForm.ps||10)){
        that.form_aaaem.disabled = true
      }
      that.conf.loading = false
      that.dataList_aaaem = res.items||[]
      that.total_aaaem = res.count
      that.resetItemData_aaaem(that,that.dataList_aaaem)
    });
  },

  resetItemData_aaaem(that,lst){
    lst.forEach(item => {
      item.__raw = Object.assign({}, item)
    item.doc_type_label = that.$theia.enum.getName("doc_type",item.doc_type)
    item.plan_id_label = that.$theia.enum.getName("dev_plan",item.plan_id)
    item.creator_label = that.$theia.enum.getName("user_account",item.creator)
    item.archive_status_label = that.$theia.enum.getName("archive_status",item.archive_status)
    item.lob_id_label = that.$theia.enum.getName("my_business_line",item.lob_id)
    item.doc_id_progress = item.doc_id
    item.tsk_id_progress = item.tsk_id
    item.doc_name_progress = item.doc_name
    item.doc_type_progress = item.doc_type
    item.plan_id_progress = item.plan_id
    item.create_time_progress = item.create_time
    item.url_progress = item.url
    item.memo_progress = item.memo
    item.creator_progress = item.creator
    item.archive_status_progress = item.archive_status
    item.lob_id_progress = item.lob_id
    item.archive_time_progress = item.archive_time
    item.le_doc_id = item.doc_id
    item.le_tsk_id = item.tsk_id
    item.le_doc_name = item.doc_name
    item.le_doc_type = item.doc_type
    item.le_plan_id = item.plan_id
    item.le_create_time = item.create_time
    item.le_url = item.url
    item.le_memo = item.memo
    item.le_creator = item.creator
    item.le_archive_status = item.archive_status
    item.le_lob_id = item.lob_id
    item.le_archive_time = item.archive_time
    if(item.children){
      that.resetItemData_aaaem(that,item.children)
    }
  });
  },
    loadEnums_aaaem(){
        //类型
        this.doc_typeList = this.$theia.enum.get("doc_type","","" ,false,"")
        //研发计划
        this.plan_idList = this.$theia.enum.get("dev_plan","",this.$theia.user.get("lob_id"),false,"")
        //归档状态
        this.archive_statusTabList = this.$theia.enum.get("archive_status","","",false,"")
        //业务线
        this.lob_idList = this.$theia.enum.getTree("my_business_line","","" ,99)
        //类型
        this.doc_typeList = this.$theia.enum.get("doc_type","","" ,false,"")
        //研发计划
        this.plan_idList = this.$theia.enum.get("dev_plan","",this.$theia.user.get("lob_id"),false,"")
        //创建人
        this.creatorList = this.$theia.enum.get("user_account","","" ,false,"")
    },

  handleSizeChange(ps){
    this.form_aaaem.ps = ps
    this.onQuery(true)
  },
  onlob_idChange(v){
    this.$theia.user.set("lob_id",v)
    this.loadEnums_aaaem()
    this.onQuery(true)
  },
  handleCurrentChange(pi){
    this.form_aaaem.pi = pi
    this.onQuery()
  },
  onQuery(refresh){
    if(refresh){
      this.form_aaaem.pi = 1
    }
    this.queryData_aaaem ()
  },
show_cmpnt(cmd,row){
  if(this.cmpnt_funcs[cmd]){
    this.cmpnt_funcs[cmd](row)
  }
},
  //详情
  show_cmpnt_aaagd(fm = {}){
    let query = {} 
    query.doc_id = fm.doc_id|| fm.le_doc_id 
    query.tsk_id = fm.tsk_id|| fm.le_tsk_id 
    query.doc_name = fm.doc_name|| fm.le_doc_name 
    query.doc_type = fm.doc_type|| fm.le_doc_type 
    query.plan_id = fm.plan_id|| fm.le_plan_id 
    query.create_time = fm.create_time|| fm.le_create_time 
    query.url = fm.url|| fm.le_url 
    query.memo = fm.memo|| fm.le_memo 
    query.creator = fm.creator|| fm.le_creator 
    query.archive_status = fm.archive_status|| fm.le_archive_status 
    query.lob_id = fm.lob_id|| fm.le_lob_id 
    query.archive_time = fm.archive_time|| fm.le_archive_time 
    query.doc_id = fm.doc_id

      //2023.4.18添加---

    query.$title="详情"
    this.$refs.cmpnt_aaagd.show(query)
  },
  //添加文档
  show_cmpnt_aaage(fm = {}){
    let query = {} 
    query.doc_name = fm.doc_name|| fm.le_doc_name 
    query.doc_type = fm.doc_type|| fm.le_doc_type 
    query.plan_id = fm.plan_id|| fm.le_plan_id 
    query.url = fm.url|| fm.le_url 
    query.memo = fm.memo|| fm.le_memo 
    query.doc_id = fm.doc_id

      //2023.4.18添加---

    query.$title="添加文档"
    this.$refs.cmpnt_aaage.show(query)
  },
  //编辑
  show_cmpnt_aaagb(fm = {}){
    let query = {} 
    query.doc_name = fm.doc_name|| fm.le_doc_name 
    query.doc_type = fm.doc_type|| fm.le_doc_type 
    query.url = fm.url|| fm.le_url 
    query.memo = fm.memo|| fm.le_memo 
    query.doc_id = fm.doc_id

      //2023.4.18添加---

    query.$title="编辑"
    this.$refs.cmpnt_aaagb.show(query)
  },
  //删除
  show_cmpnt_aaagc(fm = {}){
    let query = {} 
    query.doc_id = fm.doc_id|| fm.le_doc_id 
    query.doc_id = fm.doc_id

      //2023.4.18添加---

    query.$title="删除"
    this.$refs.cmpnt_aaagc.show_aaagc(query)
  },
},
};
</script>
<style>
.el-dialog{
  border-radius:5px !important
}
</style>
<style scoped>
.el-form-item {
  margin-right: 10px !important;
}

.opts .el-button--small {
  margin-left: 0px;
  padding-left: 0px;
  margin-right: 4px;
}

/deep/.el-table td.el-table__cell div {
  vertical-align: middle;
}
/deep/.el-button+.el-dropdown{
  margin-left:0px;
}
/deep/.el-button+.el-button{
  margin-left:0px;
}
.el-button{
  padding-left: 6px !important;
  padding-right: 6px !important;
}
.blist {
  margin-bottom: 8px;
  width: 100%;
}

.blist .el-radio-group {
  margin-right: 8px;
}

.ddl {
  margin-bottom: 8px;
  width: 100%;

}

.ddl .el-dropdown {
  margin-right: 8px;
}

.listbar {
  margin-bottom: 8px;
  text-align: center;
}
 .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
  font-size: 0.65rem;
}
/deep/.el-button--small{
  padding: 5px 4px;
}

.prepend /deep/.el-input__wrapper{
  border-top-right-radius:0;
  border-bottom-right-radius:0;
}
.prepend+/deep/.el-date-editor{
  border-top-left-radius:0;
  border-bottom-left-radius:0;
  border-left:0;
}

</style>